package map_;

import java.util.Properties;

/**
 * @author DCSGO
 * @version 1.0
 */

@SuppressWarnings({"all"})
public class Properties_ {
    //Properties 类继承自 Hashtable 类并且实现了 Map 接口
    //使用与 Hashtable 类似
    //Properties 主要用于从 xxx.properties 文件中 加载数据到
    //Properties 类对象 并进行读取和修改 (IO流时讲解)
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put("王", 10);
        properties.put("刘", 20);
        //properties.put("李",null);// 抛出异常 NullPointerException
        //properties.put(null,30);// 抛出异常 NullPointerException
        properties.put("Tom", 30);
        System.out.println(properties);//{刘=20, Tom=30, 王=10}

        //删除
        properties.remove("王");
        System.out.println(properties);//{刘=20, Tom=30}

        //修改
        properties.put("刘", 100);
        System.out.println(properties);//{刘=100, Tom=30}

        //查
        System.out.println(properties.get("Tom"));//30
    }
}
